package com.smartplatform.service.impl;

import com.smartplatform.constants.ResultCode;
import com.smartplatform.exception.QueryException;
import com.smartplatform.mapper.SysUserRoleMapper;
import com.smartplatform.service.SysUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.List;

/**
 * @Author 咕唧
 * @Date 2022/6/5 12:17
 * @Version 1.0
 */
@Service
public class SysUserRoleServiceImpl implements SysUserRoleService {
    private SysUserRoleMapper userRoleMapper;

    @Autowired
    public void setUserRoleMapper(SysUserRoleMapper userRoleMapper) {
        this.userRoleMapper = userRoleMapper;
    }

    @Override
    public List<Long> findByUId(Long uId) {

        List<Long> userRole = userRoleMapper.findByUId(uId);
        Assert.notNull(userRole, () -> {
            throw new QueryException("没有访问权限", ResultCode.USER_NOT_PERM);
        });
        return userRole;
    }
}
